package com.spi.interfaces.spi;

import java.util.Iterator;
import java.util.ServiceLoader;

public class SPIClassLoad<T> {

    public <T> T load(Class clazz){
        ServiceLoader<T> spiLoader = ServiceLoader.load(clazz);
        Iterator<T> iaIterator = spiLoader.iterator();
        while (iaIterator.hasNext()) {
            return iaIterator.next();
        }
        return null;
    }
}
